package com.butterfly.vv;

import java.util.ArrayList;
import java.util.Iterator;

import com.beem.project.beem.R;
import com.teleca.jamendo.adapter.AlbumGridAdapter;
import com.teleca.jamendo.api.Album;
import com.teleca.jamendo.dialog.ArtistLoadingDialog;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.AdapterView.OnItemClickListener;

public class ContactsGridUI extends Activity {

	private AlbumGridAdapter mAlbumGridAdapter;
	private GridView mAlbumGridView;
	
	public static void launch(Activity c, String artistName){
		new ArtistLoadingDialog(c,R.string.artist_loading, R.string.artist_fail).execute(artistName);
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.grid_2);
		mAlbumGridView = (GridView)findViewById(R.id.myGrid);
		mAlbumGridAdapter = new AlbumGridAdapter(this);
		mAlbumGridView.setOnItemClickListener(mOnItemClickListener);
		loadAlbums();
	}
	
	private void loadAlbums() {
//		JamendoGet2Api server = new JamendoGet2ApiImpl();
//		Album[] albums = server.searchForAlbumsByArtist(artistName);
		//ArrayList<Album> albums = (ArrayList<Album>)getIntent().getSerializableExtra("albums");
		ArrayList<Album> albums = new ArrayList<Album>();
		for (int i = 0; i < 4; i++) {
			albums.add(new Album());
			
		}
		mAlbumGridAdapter.setList(albums);
		mAlbumGridView.setAdapter(mAlbumGridAdapter);
	}
	
	private OnItemClickListener mOnItemClickListener = new OnItemClickListener(){

		@Override
		public void onItemClick(AdapterView<?> adapter, View view, int position,
				long time) {
			Album album = (Album)mAlbumGridAdapter.getItem(position);
//			AlbumActivity.launch(ArtistActivity.this, album);
		}

	};
}
